package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

@Entity
public class Warehousing {
    private long waId;
    private Timestamp waTime;
    private Employee employee;
    private String waDanhao;
    private String waShuoming;
    private String thdanhao;
    private List<WaouDetails> waouDetailsList;
    private String waState;
    private ReturnGoods returnGoods;
    private ExchangeGoods exchangeGoods;

    @Basic
    @Column(name="THDANHAO")
    public String getThdanhao() {
        return thdanhao;
    }

    public void setThdanhao(String thdanhao) {
        this.thdanhao = thdanhao;
    }

    @ManyToOne
    @JoinColumn(name = "exc_id", referencedColumnName = "exc_id",insertable = false,updatable = false)
    public ExchangeGoods getExchangeGoods() {
        return exchangeGoods;
    }

    public void setExchangeGoods(ExchangeGoods exchangeGoods) {
        this.exchangeGoods = exchangeGoods;
    }

    @ManyToOne
    @JoinColumn(name = "return_id", referencedColumnName = "return_id",insertable = false,updatable = false)
    public ReturnGoods getReturnGoods() {
        return returnGoods;
    }

    public void setReturnGoods(ReturnGoods returnGoods) {
        this.returnGoods = returnGoods;
    }

    @Basic
    @Column(name = "WA_State", nullable = true)
    public String getWaState() {
        return waState;
    }

    public void setWaState(String waState) {
        this.waState = waState;
    }

    @OneToMany(mappedBy = "warehousing")
    public List<WaouDetails> getWaouDetailsList() {
        return waouDetailsList;
    }

    public void setWaouDetailsList(List<WaouDetails> waouDetailsList) {
        this.waouDetailsList = waouDetailsList;
    }


    @Id
    @Column(name = "WA_ID", nullable = false, precision = 0)
    @GeneratedValue(generator  =  "seq",strategy  =  GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name  =  "seq",sequenceName  =  "crm",
            initialValue  =  1,allocationSize  =  1)
    public long getWaId() {
        return waId;
    }

    public void setWaId(long waId) {
        this.waId = waId;
    }

    @Basic
    @Column(name = "WA_TIME", nullable = true)
    public Timestamp getWaTime() {
        return waTime;
    }

    public void setWaTime(Timestamp waTime) {
        this.waTime = waTime;
    }

    @ManyToOne//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "yg_id")//设置在article表中的关联字段(外键)
    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }


    @Basic
    @Column(name = "WA_DANHAO", nullable = true, length = 255)
    public String getWaDanhao() {
        return waDanhao;
    }

    public void setWaDanhao(String waDanhao) {
        this.waDanhao = waDanhao;
    }

    @Basic
    @Column(name = "WA_SHUOMING", nullable = true, length = 255)
    public String getWaShuoming() {
        return waShuoming;
    }

    public void setWaShuoming(String waShuoming) {
        this.waShuoming = waShuoming;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Warehousing that = (Warehousing) o;
        return waId == that.waId &&
                Objects.equals(waTime, that.waTime) &&
                Objects.equals(waDanhao, that.waDanhao) &&
                Objects.equals(waShuoming, that.waShuoming);
    }

    @Override
    public int hashCode() {
        return Objects.hash(waId, waTime, waDanhao, waShuoming);
    }
}
